package com.syni.mdd.sjb.common.datatreaure.controller.protect.dataTreasure.saasminapp;

import com.syni.mdd.sjb.common.component.utils.common.annotations.CheckUserIdentity;
import com.syni.mdd.sjb.common.datatreaure.controller.BaseController;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rq.saasminapp.config.StoreIdVo;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rq.saasminapp.coupon.IdRqVo;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rq.saasminapp.goods.*;
import com.syni.mdd.sjb.common.datatreaure.service.databank.saasminapp.GoodsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@RestController
@RequestMapping("/minApp/goods")
public class GoodsController extends BaseController {

    @Autowired
    private GoodsService goodsService;

    @PostMapping("/categoryAndGoodsList")
    @ApiOperation(value = "获取商品列表")
    @CheckUserIdentity
    public Map<String,Object> categoryAndGoodsList(@RequestBody GoodListRqVo goodListRqVo){
        return goodsService.categoryAndGoodsList(goodListRqVo);
    }

    @PostMapping("/sellOutProduct")
    @ApiOperation(value = "商品手动售罄")
    @CheckUserIdentity
    public Map<String,Object> sellOutProduct(@RequestBody SellOutRqVo sellOutRqVo){
        return goodsService.sellOutProduct(sellOutRqVo);
    }

    @PostMapping("/recoverProduct")
    @ApiOperation(value = "售罄商品恢复售卖")
    @CheckUserIdentity
    public Map<String,Object> recoverProduct(@RequestBody SellOutRqVo sellOutRqVo){
        return goodsService.recoverProduct(sellOutRqVo);
    }

    @PostMapping("/goodsPutOff")
    @ApiOperation(value = "商品手动下架")
    @CheckUserIdentity
    public Map<String,Object> goodsPutOff(@RequestBody SellOutRqVo sellOutRqVo){
        return goodsService.goodsPutOff(sellOutRqVo);
    }

    @PostMapping("/goodsPutOn")
    @ApiOperation(value = "商品手动上架")
    @CheckUserIdentity
    public Map<String,Object> goodsPutOn(@RequestBody SellOutRqVo sellOutRqVo){
        return goodsService.goodsPutOn(sellOutRqVo);
    }

    @PostMapping("/goodsDetail")
    @ApiOperation(value = "获取商品详情")
    @CheckUserIdentity
    public Map<String,Object> goodsDetail(@RequestBody SellOutRqVo sellOutRqVo){
        return goodsService.goodsDetail(sellOutRqVo);
    }

    @PostMapping("/goodsDelete")
    @ApiOperation(value = "删除商品")
    @CheckUserIdentity
    public Map<String,Object> goodsDelete(@RequestBody SellOutRqVo sellOutRqVo){
        return goodsService.goodsDelete(sellOutRqVo);
    }

    @PostMapping("/goodsSaveOrUpdate")
    @ApiOperation(value = "新建/编辑商品")
    @CheckUserIdentity
    public Map<String,Object> goodsSaveOrUpdate(@RequestBody SaveOrUpdateRqVo saveOrUpdateRqVo){
        return goodsService.goodsSaveOrUpdate(saveOrUpdateRqVo);
    }

    @PostMapping("/updateSkuStock")
    @ApiOperation(value = "更新规格信息")
    @CheckUserIdentity
    public Map<String,Object> updateSkuStock(@RequestBody UpdateSkuStockRqVo updateSkuStockRqVo){
        return goodsService.updateSkuStock(updateSkuStockRqVo);
    }

    @PostMapping("/deleteSkuStock")
    @ApiOperation(value = "删除规格")
    @CheckUserIdentity
    public Map<String,Object> deleteSkuStock(@RequestBody SellOutRqVo sellOutRqVo){
        return goodsService.deleteSkuStock(sellOutRqVo);
    }

    @PostMapping("/getStoreTaste")
    @ApiOperation(value = "获取店铺口味属性列表")
    @CheckUserIdentity
    public Map<String,Object> getStoreTaste(@RequestBody StoreIdVo storeIdVo){
        return goodsService.getStoreTaste(storeIdVo);
    }

    @PostMapping("/delExtraAttribute")
    @ApiOperation(value = "删除额外属性")
    @CheckUserIdentity
    public Map<String,Object> delExtraAttribute(@RequestBody IdRqVo idRqVo){
        return goodsService.delExtraAttribute(idRqVo);
    }

    @PostMapping("/addProductAttribute")
    @ApiOperation(value = "新增商品属性")
    @CheckUserIdentity
    public Map<String,Object> addProductAttribute(@RequestBody AddProductAttributeRqVo addProductAttributeRqVo){
        return goodsService.addProductAttribute(addProductAttributeRqVo);
    }

    @PostMapping("/updateSort")
    @ApiOperation(value = "更新商品分类排序")
    @CheckUserIdentity
    public Map<String,Object> updateSort(@RequestBody UpdateSortRqVo updateSortRqVo){
        return goodsService.updateSort(updateSortRqVo);
    }

    @PostMapping("/batchUpdateSort")
    @ApiOperation(value = "批量更新商品分类排序")
    @CheckUserIdentity
    public Map<String,Object> batchUpdateSort(@RequestBody BatchUpdateSortRqVo batchUpdateSortRqVo){
        return goodsService.batchUpdateSort(batchUpdateSortRqVo);
    }

    @PostMapping("/getClassifyList")
    @ApiOperation(value = "获取分类列表")
    @CheckUserIdentity
    public Map<String,Object> getClassifyList(@RequestBody ClassifyListRqVo classifyListRqVo){
        return goodsService.getClassifyList(classifyListRqVo);
    }

    @PostMapping("/editClassify")
    @ApiOperation(value = "编辑分类")
    @CheckUserIdentity
    public Map<String,Object> editClassify(@RequestBody EditClassifyRqVo editClassifyRqVo){
        return goodsService.editClassify(editClassifyRqVo);
    }

    @PostMapping("/createClassify")
    @ApiOperation(value = "新增分类")
    @CheckUserIdentity
    public Map<String,Object> createClassify(@RequestBody CreateClassifyRqVo createClassifyRqVo){
        return goodsService.createClassify(createClassifyRqVo);
    }

    @PostMapping("/deleteClassify")
    @ApiOperation(value = "删除分类")
    @CheckUserIdentity
    public Map<String,Object> deleteClassify(@RequestBody DeleteClassifyRqVo deleteClassifyRqVo){
        return goodsService.deleteClassify(deleteClassifyRqVo);
    }

    @PostMapping("/getClassifyGoodList")
    @ApiOperation(value = "获取分类下的商品列表")
    @CheckUserIdentity
    public Map<String,Object> getClassifyGoodList(@RequestBody DeleteClassifyRqVo deleteClassifyRqVo){
        return goodsService.getClassifyGoodList(deleteClassifyRqVo);
    }

    @PostMapping("/removeProduct")
    @ApiOperation(value = "将商品从分类中移除")
    @CheckUserIdentity
    public Map<String,Object> removeProduct(@RequestBody RemoveProductRqVo removeProductRqVo){
        return goodsService.removeProduct(removeProductRqVo);
    }

}
